// Fill out your copyright notice in the Description page of Project Settings.


#include "MoveActor.h"

// Sets default values
AMoveActor::AMoveActor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	time = 0;
	Mymesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mymesh"));
	static ConstructorHelpers::FObjectFinder<UStaticMesh>MeshAssest(TEXT("StaticMesh'/Game/LevelPrototyping/Meshes/SM_Cube.SM_Cube'"));
	if (MeshAssest.Object)
	{
		Mymesh->SetStaticMesh(MeshAssest.Object);
	}
	speed = 10;
}

void AMoveActor::moveup()
{
	AddActorLocalOffset(FVector(0, 0, speed));
}

// Called when the game starts or when spawned
void AMoveActor::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void AMoveActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	moveup();
	if (time >= 2)
	{
		Destroy();
	}
	time += DeltaTime;
}

